#pragma config(Sensor, in1,    Line1,          sensorLineFollower)
#pragma config(Sensor, in2,    Line2,          sensorLineFollower)
#pragma config(Sensor, in3,    Line3,          sensorLineFollower)
#pragma config(Sensor, in4,    Line4,          sensorLineFollower)
#pragma config(Sensor, in6,    Light1,         sensorReflection)
#pragma config(Motor,  port2,           LeftMotor,     tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor,  port3,           RightMotor,    tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

///////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                           //
//     ??????   ???????     ??     ??    ??????   ??     ??    ??????   ??????? ???????      //
//   ??      ?? ??     ??   ??     ??  ??      ?? ????   ??   ??    ??  ??      ??    ??     //
//   ??      ?? ??       ??  ??   ??   ??      ?? ?? ??  ?? ??          ??      ??      ??   //
//   ?????????? ??       ??  ??   ??   ?????????? ??  ?? ?? ??          ??????? ??      ??   //
//   ??      ?? ??       ??   ?? ??    ??      ?? ??   ???? ??          ??      ??      ??   //
//   ??      ?? ??     ??     ?? ??    ??      ?? ??    ???   ??    ??  ??      ??    ??     //
//   ??      ?? ???????        ???     ??      ?? ??     ??    ??????   ??????? ???????      //
//                                                                                           //
//              @    @ @   @ @@@@     @@@@@ @@@@   @@@   @@@  @  @ @@@@ @@@@                 //
//              @    @ @@  @ @          @   @   @ @   @ @   @ @ @  @    @   @                //
//              @    @ @ @ @ @@@@       @   @@@@@ @@@@@ @     @@   @@@@ @@@@@                //
//              @    @ @  @@ @          @   @  @  @   @ @   @ @ @  @    @  @                 //
//              @@@@ @ @   @ @@@@       @   @   @ @   @  @@@  @  @ @@@@ @   @                //
//                                                                                           //
///////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                           //
//                               Made by Jacqui L. and Ali A.                                //
//                                         In beta                                           //
//                                                                                           //
///////////////////////////////////////////////////////////////////////////////////////////////

task main(){
    while(true){
       if(SensorValue(Line2)>=2800 && SensorValue(Line3)>=2800){ // <-- Then the line following conditional
        //Backing up robot
          motor[LeftMotor] =-90;
          motor[RightMotor]=-90;
       }
       //Right sensor is on the line
       else if(SensorValue(Line2)>=2800){
           motor[LeftMotor] =25;
           motor[RightMotor]=-127;
       }
       //Left sensor is on the line
       else if(SensorValue(Line3)>=2800){
          motor[LeftMotor] =-120;
          motor[RightMotor]=30;
       }
       else   if(SensorValue(Line1)<=1980&& SensorValue(Line4)<=1950 ){ // <-- Starting off with the line avoding conditional
       //Backing up the robot at max speed for 2 seconds
           motor[LeftMotor]=-30;
           motor[RightMotor]=-127;
           wait1Msec(750);
       }
       //Detecting if the left sensor is over the green line
       else if(SensorValue(Line4)<=1975){
         motor[LeftMotor]=20;
         motor[RightMotor]=-127;}
      //Detecting if the right sensor is over the green line
       else if(SensorValue(Line1)<=2000){
         //Turning the robot left
         motor[LeftMotor]=-127;
         motor[RightMotor]=20;
         }
      //If neither sensor is over the green line
       else{
         //Moving the robot foward
         motor[LeftMotor]=30; //Value is higher because this motor is weaker
         motor[RightMotor]=34; //Value is lower because this motor is stronger
      }
   } // <-- End of the while loop
} // <-- End of the main task
